package com.jun.resttemplatetest;

import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.core.JsonEncoding;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Map;

@RestController
public class JinSeController {

    String url = "https://api.jinse.com/v6/information/list?catelogue_key=zhuanlantuijian&limit={limit}&information_id={id}&flag=down&version=9.9.9";
    Map<String,Object> params= new HashMap<>();
    Integer id = 1059513;
    @GetMapping("/jinse")
    @Scheduled(fixedDelay = 3000)
    public Object JinSe(){
        RestTemplate restTemplate = new RestTemplate();
        params.put("limit",5);
        params.put("id",id);
        String res = restTemplate.getForObject(url,String.class,params);
        JiSe j = JSON.parseObject(res,JiSe.class);
        System.out.println("结果："+j);
        id = j.getBottomId();
       return j;
    }
}
